<?php

function smarty_function_getcategory_by_subcat_id($params, &$smarty) {
    //Get value from page
    $id = $params['subcat_id'];
    if($id){

      $pntables = pnDBGetTables();
      $tableCategory  = $pntables['innoforum_category'];
      $columncategory = $pntables['innoforum_category_column'];
      $tableSubCategory  = $pntables['innoforum_subcategory'];
      $columnSubCategory = $pntables['innoforum_subcategory_column'];


      //Query data
      $sql = "SELECT
                $tableCategory.$columncategory[id],  
                $tableCategory.$columncategory[name]  
              FROM 
                $tableCategory,
                $tableSubCategory
              WHERE
                $tableCategory.$columncategory[id] = $tableSubCategory.$columnSubCategory[category_id]
              AND
                $tableSubCategory.$columnSubCategory[category_id] = ".$id;
      $column = array("category_id","category_name");
      $result = DBUtil::executeSQL($sql);
      $objectArray = DBUtil::marshallObjects ($result, $column);
      echo $objectArray['0']['category_name'];
    }


}